<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%String path = request.getContextPath();%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <jsp:include page="../../import.jsp" flush="true"/>
    <jsp:include page="../../ass/assParking/assParkCommon.jsp" flush="true"/>
    <script type="text/javascript" src="<%=path %>/resource/lib/plugins/ajaxfileupload.js"></script>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div>
        <div id="pageInTab" class="pageInTab">
            <!-- 页签1-->
            <div tabid="tabA" title="线下赎回支付表导入" lselected="true">
                <div class="searchArea">
                    <form id="searchBar">
                        <div class="fieldset1 clearFix">
                            <!-- 表单按钮 -->
                            <div class="btnsBox formBtns notRight">
                                <input id="upfile" name="upfile" style="width:200px" type="file">
                                <span id="upBtn" class="sq-button-round" onclick="uploadExcel();">导入</span>
                                <span id="downTempBtn" class="sq-button sq-button-round" onclick="downTemp();">下载模板</span>
                            </div>
                        </div>
                    </form>
                </div>
                <!-- 列表显示块 -->
                <div id="ligergrid1" class="sq-grid"></div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var pageInApp = {
        flag: false //tab页验证关闭
    };//to下一级子窗口 接口
    var pageInTab = null;//页签
    var loadedTabs = [];//页签
    var grid = null;

    $(function () {
        initLigerGrid({});
    });
    function initLigerGrid(data) {
        $("#ligergrid1").ligerGrid({
            data: data,
            columns: [
                {display: '支付表编号', name: 'paySchNo', width: 300},
                {display: '融资机构代码', name: 'insCode', width: 150},
                {display: '状态', name: 'payStsCdNm', width: 300},
                {display: '上传人', name: 'cstMgrNm', width: 150},
                {display: '上传时间', name: 'crtTm', width: 150,render: renderDate}
            ],
            pageSize: 20,
            pageSizeOptions: [20, 30, 50, 100, 500, 1000],
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            checkbox:true,
            allowUnSelectRow: true,
            alternatingRow: true,
            rownumbers:true,
            enabledEdit: false,
            fixedCellHeight: false,
            usePagerOnLessPagesize: true,
        });
        grid = liger.get("ligergrid1");
        grid.setHeight(800);
        $("#searchBar").ligerForm();
    }

    function downTemp(){
        window.location.href="<%=path%>/resource/template/reffile/payImportDemo.xls";
    }
</script>
<script type="text/javascript">
    //导入模版
    function uploadExcel() {
        var wait_dialog = $.ligerDialog.SQalert({content: '上传中,请稍后...', SQ_type: "waitting"});
        $.ajaxFileUpload({
            url: "<%=path%>/ref/fncprjprdpaysch/fncPrjPrdPaySchM/importExcel.do",
            dataType: 'json',
            data: {},
            secureuri: false,
            fileElementId: 'upfile',
            success: function (msg) { //服务器成功响应处理函数
                wait_dialog.close();
                if (msg.success == 1) {
                    initLigerGrid(msg.data);
                } else {
                    initLigerGrid({});
                    $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                wait_dialog.close();
                $.ligerDialog.SQalert({content: "网络错误，请稍后重试", SQ_type: "error"});
            }
        });
    }

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }
</script>
</body>
</html>